package com.yowasa.xiuxian.engine.item.danyao;

import cn.hutool.core.util.RandomUtil;
import com.yowasa.xiuxian.annoations.Item;
import com.yowasa.xiuxian.engine.item.ItemInterface;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ItemTypeEnum;
import com.yowasa.xiuxian.exception.HandlerException;

import java.util.ArrayList;
import java.util.Map;
import java.util.Set;

@Item(name = "万民堂水煮鱼", type = ItemTypeEnum.DAN_YAO, price = 8000)
public class WanMingTangShuiZhuYu implements ItemInterface {

    @Override
    public String desc() {
        return "随机重置一个灵药的使用次数，包括鲜香锅巴";
    }

    @Override
    public String effect(UserBO userBO) {
        Map<String, Integer> lingYaoTag = userBO.getUserConfig().getLingYaoTag();
        Set<String> strings = lingYaoTag.keySet();
        if(strings.size() == 0){
            throw new HandlerException("你当前没有使用过灵药");
        }
        ArrayList<String> list = new ArrayList<>(strings);
        String s = RandomUtil.randomEle(list);
        lingYaoTag.remove(s);

        userBO.getUserConfig().setLingYaoTag(lingYaoTag);
        return "灵药: ["+s+"] 的使用次数已经重制";
    }



}
